
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>2.3 Phoenix 表映射 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../di-3-zhang-phoenix-tu-xing-hua-gong-51773a-squirrel.html" />
    
    
    <link rel="prev" href="22-phoenix-biao-cao-zuo.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    第 1 章 Phoenix 简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter1.html">
            
                <a href="../chapter1.html">
            
                    
                    第 2 章 Phoenix 快速入门
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="21-an-zhuang-bu-shu.html">
            
                <a href="21-an-zhuang-bu-shu.html">
            
                    
                    2.1 安装部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="22-phoenix-biao-cao-zuo.html">
            
                <a href="22-phoenix-biao-cao-zuo.html">
            
                    
                    2.2 Phoenix 表操作
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.3" data-path="23-phoenix-biao-ying-she.html">
            
                <a href="23-phoenix-biao-ying-she.html">
            
                    
                    2.3 Phoenix 表映射
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../di-3-zhang-phoenix-tu-xing-hua-gong-51773a-squirrel.html">
            
                <a href="../di-3-zhang-phoenix-tu-xing-hua-gong-51773a-squirrel.html">
            
                    
                    第 3 章 Phoenix 图形化工具: Squirrel
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin.html">
            
                <a href="../di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin.html">
            
                    
                    第 4 章 Phoenix 创建 HBase 二级索引
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/41-hbase-de-er-ji-suo-yin.html">
            
                <a href="../di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/41-hbase-de-er-ji-suo-yin.html">
            
                    
                    4.1 HBase 的二级索引
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/42-pei-zhi-hbase-zhi-chi-phoenix-chuang-jian-er-ji-suo-yin.html">
            
                <a href="../di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/42-pei-zhi-hbase-zhi-chi-phoenix-chuang-jian-er-ji-suo-yin.html">
            
                    
                    4.2 配置 HBase 支持 Phoenix 创建二级索引
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/43-chuang-jian-suo-yin.html">
            
                <a href="../di-4-zhang-phoenix-chuang-jian-hbase-er-ji-suo-yin/43-chuang-jian-suo-yin.html">
            
                    
                    4.3 Phoenix 创建索引
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >2.3 Phoenix 表映射</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="23-phoenix-&#x8868;&#x6620;&#x5C04;">2.3 Phoenix &#x8868;&#x6620;&#x5C04;</h1>
<h2 id="231-phoenix-&#x8868;&#x548C;-hbase-&#x8868;&#x7684;&#x5173;&#x7CFB;">2.3.1 Phoenix &#x8868;&#x548C; HBase &#x8868;&#x7684;&#x5173;&#x7CFB;</h2>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;, &#x76F4;&#x63A5;&#x5728; HBase &#x4E2D;&#x521B;&#x5EFA;&#x7684;&#x8868;&#x901A;&#x8FC7; Phoenix &#x662F;&#x67E5;&#x4E0D;&#x5230;&#x7684;. </p>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1566794824.png" alt=""></p>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1566794930.png" alt=""></p>
<p>&#x5982;&#x679C;&#x8981;&#x5728; Phoenix &#x4E2D;&#x64CD;&#x4F5C;&#x76F4;&#x63A5;&#x5728; HBase &#x4E2D;&#x521B;&#x5EFA;&#x7684;&#x8868;&#xFF0C;&#x5219;&#x9700;&#x8981;&#x5728; Phoenix &#x4E2D;&#x8FDB;&#x884C;&#x8868;&#x7684;&#x6620;&#x5C04;&#x3002;</p>
<p>&#x6620;&#x5C04;&#x65B9;&#x5F0F;&#x6709;&#x4E24;&#x79CD;&#xFF1A;</p>
<ol>
<li>&#x89C6;&#x56FE;&#x6620;&#x5C04;</li>
<li>&#x8868;&#x6620;&#x5C04;</li>
</ol>
<h2 id="232-&#x51C6;&#x5907;&#x5DE5;&#x4F5C;">2.3.2 &#x51C6;&#x5907;&#x5DE5;&#x4F5C;</h2>
<p>&#x5728; HBase &#x4E2D;&#x521B;&#x5EFA;&#x8868;: <code>test</code>, &#x4E24;&#x4E2A;&#x5217;&#x7C07;<code>name</code>&#x3001;<code>company</code>.</p>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1566795607.png" alt=""></p>
<ol>
<li><p>&#x542F;&#x52A8; HBase shell</p>
</li>
<li><p>&#x521B;&#x5EFA;&#x8868;: <code>test</code></p>
<pre><code class="lang-bash"> create <span class="hljs-string">&apos;test&apos;</span>, <span class="hljs-string">&apos;name&apos;</span>, <span class="hljs-string">&apos;company&apos;</span>
</code></pre>
<p>&#x5728; Phoenix &#x4E2D;&#x662F;&#x770B;&#x4E0D;&#x5230;&#x8FD9;&#x4E2A;&#x8868;&#x7684;:
<img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1566806835.png" alt=""></p>
</li>
</ol>
<h2 id="233-&#x89C6;&#x56FE;&#x6620;&#x5C04;">2.3.3 &#x89C6;&#x56FE;&#x6620;&#x5C04;</h2>
<p>Phoenix &#x521B;&#x5EFA;&#x7684;&#x89C6;&#x56FE;&#x662F;&#x53EA;&#x8BFB;&#x7684;, &#x6240;&#x4EE5;&#x53EA;&#x80FD;&#x7528;&#x6765;&#x67E5;&#x8BE2;, &#x65E0;&#x6CD5;&#x901A;&#x8FC7;&#x89C6;&#x56FE;&#x5BF9;&#x6570;&#x636E;&#x8FDB;&#x884C;&#x4FEE;&#x6539;&#x7B49;&#x64CD;&#x4F5C;.</p>
<pre><code class="lang-bash">create view <span class="hljs-string">&quot;test&quot;</span>(empid varchar primary key,<span class="hljs-string">&quot;name&quot;</span>.<span class="hljs-string">&quot;firstname&quot;</span> varchar,<span class="hljs-string">&quot;name&quot;</span>.<span class="hljs-string">&quot;lastname&quot;</span> varchar,<span class="hljs-string">&quot;company&quot;</span>.<span class="hljs-string">&quot;name&quot;</span> varchar,<span class="hljs-string">&quot;company&quot;</span>.<span class="hljs-string">&quot;address&quot;</span> varchar);
</code></pre>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1566806949.png" alt=""></p>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1566807279.png" alt=""></p>
<h2 id="234-&#x8868;&#x6620;&#x5C04;">2.3.4 &#x8868;&#x6620;&#x5C04;</h2>
<p>&#x4F7F;&#x7528; Phoenix&#x521B;&#x5EFA;&#x5BF9; HBase &#x7684;&#x8868;&#x6620;&#x5C04;&#xFF0C;&#x6709;&#x4E24;&#x79CD;&#x65B9;&#x6CD5;&#xFF1A;</p>
<ol>
<li><p>&#x5F53; HBase &#x4E2D;&#x5DF2;&#x7ECF;&#x5B58;&#x5728;&#x8868;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x4EE5;&#x7C7B;&#x4F3C;&#x521B;&#x5EFA;&#x89C6;&#x56FE;&#x7684;&#x65B9;&#x5F0F;&#x521B;&#x5EFA;&#x5173;&#x8054;&#x8868;&#xFF0C;&#x53EA;&#x9700;&#x8981;&#x5C06;<code>create view</code> &#x6539;&#x4E3A; <code>create table</code> &#x5373;&#x53EF;&#x3002;
&#x5728; HBase &#x4E2D;&#x521B;&#x5EFA;&#x8868;: </p>
<pre><code class="lang-sql"><span class="hljs-keyword">create</span> <span class="hljs-string">&apos;test1&apos;</span>, <span class="hljs-string">&apos;name&apos;</span>, <span class="hljs-string">&apos;company&apos;</span>
</code></pre>
<p>&#x5728; Phoenix &#x4E2D;&#x521B;&#x5EFA;&#x5173;&#x8054;&#x8868;:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span> <span class="hljs-string">&quot;test1&quot;</span>(empid <span class="hljs-built_in">varchar</span> primary <span class="hljs-keyword">key</span>,<span class="hljs-string">&quot;name&quot;</span>.<span class="hljs-string">&quot;firstname&quot;</span> <span class="hljs-built_in">varchar</span>,<span class="hljs-string">&quot;name&quot;</span>.<span class="hljs-string">&quot;lastname&quot;</span> <span class="hljs-built_in">varchar</span>,<span class="hljs-string">&quot;company&quot;</span>.<span class="hljs-string">&quot;name&quot;</span> <span class="hljs-built_in">varchar</span>,<span class="hljs-string">&quot;company&quot;</span>.<span class="hljs-string">&quot;address&quot;</span> <span class="hljs-built_in">varchar</span>) column_encoded_bytes=<span class="hljs-number">0</span>;
</code></pre>
<p>&#x8BF4;&#x660E;: &#x6DFB;&#x52A0;&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#x4E4B;&#x540E;, &#x5728; HBase &#x4E2D;&#x6DFB;&#x52A0;&#x7684;&#x6570;&#x636E;&#x5728; Phoenix &#x4E2D;&#x4E5F;&#x53EF;&#x4EE5;&#x67E5;&#x8BE2;&#x5230;. &#x5426;&#x5219; HBase &#x4E2D;&#x6DFB;&#x52A0;&#x7684;&#x6570;&#x636E;&#x5728; Phoenix &#x4E2D;&#x67E5;&#x8BE2;&#x4E0D;&#x5230;.</p>
</li>
<li><p>&#x5F53; HBase &#x4E2D;&#x4E0D;&#x5B58;&#x5728;&#x8868;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528; <code>create table</code> &#x6307;&#x4EE4;&#x521B;&#x5EFA;&#x9700;&#x8981;&#x7684;&#x8868;,&#x7CFB;&#x7EDF;&#x5C06;&#x4F1A;&#x81EA;&#x52A8;&#x5728; Phoenix &#x548C; HBase &#x4E2D;&#x521B;&#x5EFA; person_infomation &#x7684;&#x8868;&#xFF0C;&#x5E76;&#x4F1A;&#x6839;&#x636E;&#x6307;&#x4EE4;&#x5185;&#x7684;&#x53C2;&#x6570;&#x5BF9;&#x8868;&#x7ED3;&#x6784;&#x8FDB;&#x884C;&#x521D;&#x59CB;&#x5316;&#x3002;</p>
</li>
</ol>
<h2 id="235-&#x89C6;&#x56FE;&#x6620;&#x5C04;&#x548C;&#x8868;&#x6620;&#x5C04;&#x7684;&#x5BF9;&#x6BD4;&#x4E0E;&#x603B;&#x7ED3;">2.3.5 &#x89C6;&#x56FE;&#x6620;&#x5C04;&#x548C;&#x8868;&#x6620;&#x5C04;&#x7684;&#x5BF9;&#x6BD4;&#x4E0E;&#x603B;&#x7ED3;</h2>
<p>&#x76F8;&#x6BD4;&#x4E8E;&#x76F4;&#x63A5;&#x521B;&#x5EFA;&#x6620;&#x5C04;&#x8868;&#xFF0C;&#x89C6;&#x56FE;&#x7684;&#x67E5;&#x8BE2;&#x6548;&#x7387;&#x4F1A;&#x4F4E;&#xFF0C;
&#x539F;&#x56E0;&#x662F;&#xFF1A;&#x521B;&#x5EFA;&#x6620;&#x5C04;&#x8868;&#x7684;&#x65F6;&#x5019;&#xFF0C;Phoenix &#x4F1A;&#x5728;&#x8868;&#x4E2D;&#x521B;&#x5EFA;&#x4E00;&#x4E9B;&#x7A7A;&#x7684;&#x952E;&#x503C;&#x5BF9;&#xFF0C;&#x8FD9;&#x4E9B;&#x7A7A;&#x952E;&#x503C;&#x5BF9;&#x7684;&#x5B58;&#x5728;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x63D0;&#x9AD8;&#x67E5;&#x8BE2;&#x6548;&#x7387;&#x3002;</p>
<p>&#x4F7F;&#x7528;<code>create table</code>&#x521B;&#x5EFA;&#x7684;&#x5173;&#x8054;&#x8868;&#xFF0C;&#x5982;&#x679C;&#x5BF9;&#x8868;&#x8FDB;&#x884C;&#x4E86;&#x4FEE;&#x6539;&#xFF0C;&#x6E90;&#x6570;&#x636E;&#x4E5F;&#x4F1A;&#x6539;&#x53D8;&#xFF0C;&#x540C;&#x65F6;&#x5982;&#x679C;&#x5173;&#x8054;&#x8868;&#x88AB;&#x5220;&#x9664;&#xFF0C;&#x6E90;&#x8868;&#x4E5F;&#x4F1A;&#x88AB;&#x5220;&#x9664;&#x3002;&#x4F46;&#x662F;&#x89C6;&#x56FE;&#x5C31;&#x4E0D;&#x4F1A;&#xFF0C;&#x5982;&#x679C;&#x5220;&#x9664;&#x89C6;&#x56FE;&#xFF0C;&#x6E90;&#x6570;&#x636E;&#x4E0D;&#x4F1A;&#x53D1;&#x751F;&#x6539;&#x53D8;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="22-phoenix-biao-cao-zuo.html" class="navigation navigation-prev " aria-label="Previous page: 2.2 Phoenix 表操作">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../di-3-zhang-phoenix-tu-xing-hua-gong-51773a-squirrel.html" class="navigation navigation-next " aria-label="Next page: 第 3 章 Phoenix 图形化工具: Squirrel">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"2.3 Phoenix 表映射","level":"1.2.3","depth":2,"next":{"title":"第 3 章 Phoenix 图形化工具: Squirrel","level":"1.3","depth":1,"path":"di-3-zhang-phoenix-tu-xing-hua-gong-51773a-squirrel.md","ref":"di-3-zhang-phoenix-tu-xing-hua-gong-51773a-squirrel.md","articles":[]},"previous":{"title":"2.2 Phoenix 表操作","level":"1.2.2","depth":2,"path":"chapter1/22-phoenix-biao-cao-zuo.md","ref":"chapter1/22-phoenix-biao-cao-zuo.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"chapter1/23-phoenix-biao-ying-she.md","mtime":"2019-08-26T09:48:33.617Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-08-27T02:14:08.566Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

